﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Starfire3d.Interfaces;

namespace Starfire3d.Data.Objects
{
    public class ShipClass : IDataItem
    {
        #region Attributes
        private string shipShortClass;
        private string shipLongClass;
        private int size;
        private int minHull;
        private int maxHull;
        private double cost;
        private int engineSize;
        private int maxSpeed;
        private int turnMode;
        private int minElLevel;
        #endregion

        #region Constructor
        public ShipClass()
        {
        }
        #endregion

        #region Properties
        public string ShortClassName
        {
            get { return shipShortClass; }
        }
        public string LongClassName
        {
            get { return shipLongClass; }
        }
        public int Size
        {
            get { return size; }
        }
        public int MinHull
        {
            get { return minHull; }
        }
        public int MaxHull
        {
            get { return maxHull; }
        }
        public double Cost
        {
            get { return cost; }
        }
        public int EngineSize
        {
            get { return engineSize; }
        }
        public int MaxSpeed
        {
            get { return maxSpeed; }
        }
        public int TurnMode
        {
            get { return turnMode; }
        }
        public int MinElLevel
        {
            get { return minElLevel; }
        }
        #endregion

        #region Public Methods;
        public bool BuildFromMetaData(MetaObject meta)
        {
            foreach (string token in meta.TokenList)
            {
                string[] tokens = token.Split(':');

                if (tokens[0].ToLower() == "type")
                {
                    shipShortClass = tokens[1];
                    shipLongClass = tokens[2];
                    continue;
                }
                if (tokens[0].ToLower() == "size")
                {
                    size = int.Parse(tokens[1]);
                    continue;
                }
                if (tokens[0].ToLower() == "hull")
                {
                    minHull = int.Parse(tokens[1]);
                    maxHull = int.Parse(tokens[2]);
                    continue;
                }
                if (tokens[0].ToLower() == "cost")
                {
                    cost = double.Parse(tokens[1]);
                    continue;
                }
                if (tokens[0].ToLower() == "enginesize")
                {
                    engineSize = int.Parse(tokens[1]);
                    continue;
                }
                if (tokens[0].ToLower() == "maxspeed")
                {
                    maxSpeed = int.Parse(tokens[1]);
                    continue;
                }
                if (tokens[0].ToLower() == "turnmode")
                {
                    turnMode = int.Parse(tokens[1]);
                    continue;
                }
                if (tokens[0].ToLower() == "el")
                {
                    minElLevel = int.Parse(tokens[1]);
                    continue;
                }
            }

            return true;
        }

        public override string ToString()
        {
            return shipShortClass;
        }
        #endregion

        #region IDataItem Members

        public bool IsDestroyed
        {
            get { return false; }
        }

        #endregion
    }
}
